﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lilium.LParse.Expressions
{
    public static class Operator
    {
        public static BinaryOperator<TToken, TResult> BinaryOperator<TToken, TResult>(
            Parser<TToken, TResult> parser,
            int priority,
            Func<TResult, TResult> op,
            Associativity associativity)
        {
            return new BinaryOperator<TToken, TResult>(parser, priority, op, associativity);
        }
    }

    public abstract class Operator<TToken, TResult>
    {
        public Operator(Parser<TToken, TResult> parser, int priority)
        {
            if (parser == null) throw new ArgumentNullException("parser");

            m_Parser = parser;
            m_Priority = priority;
        }

        #region public int Priority

        private readonly int m_Priority;

        public int Priority { get { return m_Priority; } }

        #endregion

        #region public Parser<TToken, TResult> Parser

        private readonly Parser<TToken, TResult> m_Parser;

        public Parser<TToken, TResult> Parser { get { return m_Parser; } }

        #endregion
    }
}